import * as React from "react";

export default function Ref() {
  const divEl = React.useRef(null);
  const El = React.useRef(null);
  const onButtonClick = () => {
    // `current` 指向已挂载到 DOM 上的文本输入元
    console.log("don节点：");
    console.log(divEl.current);
    console.log("组件：");
    console.log(El.current);
  };
  return (
    <>
      <div ref={divEl}>这是一个dom节点</div>
      <Com ref={El} />
      <button onClick={onButtonClick}>控制台打印</button>
    </>
  );
}

class Com extends React.Component {
  render() {
    return <div>这是一个组件</div>;
  }
}
